var form, $, table;

$(function () {
    initDataGrid("/inprocess/queryInProcessList.do");
});

/**
 * 表格
 * @returns
 */
function initDataGrid(url) {
    table = layui.table;
    var params = $("#searchForm").serializeObject();
    console.log(params);
    table.render({
        elem: '#inProcessDataTable',
        url: url,
        page: true,
        where: params,
        id: "inProcessDataTable",
        text: {none: '暂无办理中生产信息'},
        cols: [[
            {checkbox: true, fixed: true},
            {field: 'scProductOrderNo', title: '生产订单编号'},
            {field: 'latestEndNodeName', title: '当前节点'},
            {field: 'customerName', title: '客户名称'},
            {field: 'businessTypeName', title: '业务名称'},
            {field: 'productName', title: '订单商品'},
            {field: 'contractNo', title: '合同编号'},
            {field: 'flowUserName', title: '流程人员姓名'},
            {field: 'flowUserOrgName', title: '流程人员部门'},
            {title: "操作", toolbar: '#dataTableFilter'}
        ]]
    });
    DGG.loading("close");

    /**
     * 监听工具条
     */
    table.on('tool(dataTableFilter)', function (obj) {
        if (obj.event === 'handover') {
            console.log(obj.data);
            handOverFlowUser(obj.data);
        }
    });
}

/**
 * 移交
 */
function handOverFlowUser(data) {
    $.post(sysInfo.basePath + "/inprocess/handOverUser.do", {}, function (html) {
        open(html, data.id)
    }, 'html');
}

/**
 * 弹出框
 */
var open = function (html, id) {
    layer.open({
        type: 1,
        title: name + "转单",
        content: html,
        offset: '100px',
        area: ['600px', '250px'],
        success: function (layero, index) {
            if (id) {
                $('#id').val(id);
            }
        }
    });
}
